<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<!-- AUTHOR: Dakota -->
<html xmlns="http://www.w3.org/1999/xhtml"   
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      >
    <body>
        <ui:composition>
            <h:form>
                <h:panelGrid id="completeGrid" columns="5">
                    <h:outputText value="Choose a student:"/>
                    <h:selectOneMenu id="studentlist" value="#{gradeExerciseBean.studentChosen}"  >  
                        <f:selectItems value="#{gradeExerciseBean.studentsValue}"/>
                    </h:selectOneMenu>
                    <h:outputText value="Choose an Exercise (assigned by instructor):"/>
                    <h:selectOneMenu id="exerciselist" value="#{gradeExerciseBean.assignedItem}"  >  
                        <f:selectItems value="#{gradeExerciseBean.assignedValue}"/>
                    </h:selectOneMenu>
                    <p:commandButton value="Choose&nbsp;an&nbsp;Exercise" process="@form" action="#{gradeExerciseBean.chooseExercise}" update=":tabForm:growl exercisePanel"/>
                </h:panelGrid>
                
                <p:outputPanel id="exercisePanel">
                        
                        <p:outputPanel id="descSource" rendered="#{gradeExerciseBean.isChosen}">
                            <!-- SCORE -->
                            <h:panelGrid columns="3" style=" margin-left: 60%;">
                                <h:outputText value="Current Score: " />
                                <p:inputText value="#{gradeExerciseBean.score}"/>
                                <p:commandButton value="Save&nbsp;Score" process="@form" update=":tabForm:growl descSource" action="#{gradeExerciseBean.saveScore}"/>
                            </h:panelGrid>
                            
                            <!-- DATE EXTENSION -->
                            <h:panelGrid columns="5" cellspacing="15px">
                                <h:outputText value="Due Date:" style="font-weight: bold; "/>
                                <h:outputText value="#{gradeExerciseBean.exercise.dueDate}"/>
                                <h:outputText value="Individual Due Date Extention: " style="font-weight: bold;"/>
                                <p:calendar value="#{gradeExerciseBean.date}" id="popupButtonCal"/>  
                                <p:commandButton value="Extend&nbsp;Exercise" process="@form" update=":tabForm:growl descSource" action="#{gradeExerciseBean.extendDate}"/>
                            </h:panelGrid>
                            
                            <!-- EXERCISE -->
                            <p:fieldset legend="Description" style=" width: 60%;">
                                <h:outputText value="#{gradeExerciseBean.assignment.exerciseDescription}" style="padding-top:30px; padding-bottom:30px; margin-bottom: 30px;" />
                            </p:fieldset>
                            <p:fieldset legend="Source Code" style="margin-top: 30px; width: 60%">
                                <p:inputTextarea id="exerciseinput" value ="#{gradeExerciseBean.content}" rows="20" style="width: 100%"  autoResize="false" />
                            </p:fieldset>
                        </p:outputPanel>

                        <p:outputPanel rendered="#{gradeExerciseBean.isChosen}">
                            <p:commandButton value="Save/Compile/Run" process="@form" update=":tabForm:stickygrowl descSource runPanel" action="#{gradeExerciseBean.compileSaveRunCode}" />
                        </p:outputPanel>

                        <!-- RUN RESULTS -->
                        <p:outputPanel id="runPanel" rendered="#{gradeExerciseBean.isChosen}">
                            <p:fieldset legend="Run Output" rendered="#{gradeExerciseBean.isExecuted}" style="margin-top: 30px;">
                                <h:outputText value="#{gradeExerciseBean.run1}" escape="false" />
                                <h:outputText value="#{gradeExerciseBean.run2}" escape="false" />
                                <h:outputText value="#{gradeExerciseBean.run3}" escape="false" />                  
                            </p:fieldset>
                        </p:outputPanel>
                    </p:outputPanel>
            </h:form>
        </ui:composition>
    </body>
</html>
